﻿/****************************************************************************************************
	Copyright (C) 2010 RapidWebDev Organization (http://rapidwebdev.org)
	Author: Eunge, Legal Name: Jian Liu, Email: eunge.liu@RapidWebDev.org

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************************************/

using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;

namespace RapidWebDev.SearchIndex.Contract
{
	/// <summary>
	/// Selector message to specify which part of searched document should be returned from search service.
	/// </summary>
	[Serializable]
	[DataContract(Namespace = ServiceNamespaces.SearchIndexNamespace)]
	public class SearchResultSelectorMessage
	{
		/// <summary>
		/// True to return the highlight fragment of the searched documents by the keyword, defaults to false.
		/// </summary>
		[DataMember]
		public bool ReturnKeywordHighlightFragment { get; set; }

		/// <summary>
		/// True to return the attachments of the searched documents, defaults to false.
		/// </summary>
		[DataMember]
		public bool ReturnDocAttachments { get; set; }

		/// <summary>
		/// Only the special fields of the searched documents should be returned from search service.
		/// If the property equals to NULL, it indicates to return all fields of result docs.
		/// </summary>
		[DataMember]
		public Collection<SearchResultFieldSelectorMessage> ReturnOnlySpecialFields { get; set; }
	}

	/// <summary>
	/// The class is used to specify which fields of result docs should be returned from search service.
	/// </summary>
	[Serializable]
	[DataContract(Namespace = ServiceNamespaces.SearchIndexNamespace)]
	public class SearchResultFieldSelectorMessage
	{
		/// <summary>
		/// Empty constructor.
		/// </summary>
		public SearchResultFieldSelectorMessage()
		{
		}

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="fieldName"></param>
		public SearchResultFieldSelectorMessage(string fieldName)
		{
			this.FieldName = fieldName;
		}

		/// <summary>
		/// Field name.
		/// </summary>
		[DataMember]
		public string FieldName { get; set; }

		/// <summary>
		/// True to enable highlight fragment in the field of result docs, defaults to false.
		/// </summary>
		[DataMember]
		public bool EnableHighlightFragment { get; set; }
	}
}